<% layout('/layouts/default.html', {title: '来文登记表管理', libs: ['validate']}){ %>

    <style>
        .form-error{
            color: white;
        }
    </style>

<div class="main-content" >
    <div class="box box-main">
        <div class="box-header with-border">
            <div class="box-title">
                <i class="fa icon-note"></i> ${text('确定领文信息' )}
                <!--  <i style="position: absolute;top: 0;margin-left: 10%;display: none" id="faceShow">
                    <img style="height: 50px;cursor: pointer;border-radius: 50px" id="showImg" src="${ctxStatic}/camera.jpg" class="img-responsive fa icon-note" title="拍照" onclick="collectPicture()"></i>-->

            </div>
            <div class="box-tools pull-right">
                <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
            </div>
        </div>
        <#form:form id="inputForm" model="${docRecv}" action="${ctx}/sd/docDeliverRecord/takeFile?takecode=" method="post" class="form-horizontal">
        <div class="box-body">
            <div class="form-unit">${text('基本信息')}</div>
            <#form:hidden path="id"/>
            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required ">*</span> ${text('来文标题')}：<i class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
                            <#form:input path="docTitle" maxlength="500" readonly="true" class="form-control required"/>
                        </div>
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required ">*</span> ${text('来文文号')}：<i class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
                            <#form:input path="docFullNum" maxlength="100" readonly="true" class="form-control required"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required ">*</span> ${text('来文自编号')}：<i class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
                            <#form:input path="docSysCode" maxlength="100" readonly="true" class="form-control required"/>
                        </div>
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required ">*</span> ${text('紧急程度')}：<i class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
                            <#form:select path="docEmergLvl" dictType="recv_doc_emerg_lvl" readonly="true"  class="form-control required" />
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required ">*</span> ${text('密级')}：<i class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
                            <#form:select path="secLvl" dictType="recv_sec_lvl" readonly="true" class="form-control required" />
                        </div>
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required ">*</span> ${text('来文日期')}：<i class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
                            <#form:input path="docRecvDate" readonly="true" maxlength="20" class="form-control  required"
                            dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                 <div class="col-xs-6">
                    <div class="form-group">

                        <label class="control-label col-sm-4" title="" >
                            <span class="required ">*</span> ${text('领文人选择')}：<i class="fa icon-question hide"></i></label>
                        <div class="col-sm-8" id="opt">


                            <!--<div class="input-group treeselect" id="testUserDiv" data-url="/a/sys/office/treeData?isLoadUser=true">

                           <#form:treeselect id="testUser" title="用户选择" required="true" path="userCode" labelPath="testUser.userName"
                                url="${ctx}/sys/office/treeData?isLoadUser=true" class="required" allowClear="true"/>
                             </div>-->
                            <#form:select path="moduleCodes" onchange="getUser()" items="${empList}" itemLabel="empName" id="user" itemValue="empCode" blankOption="true" class="form-control " />
                            <#form:input path="showUserId" onfocus="get()" placeholder="输入领文人姓名或挑选领文人" onblur="left()" id="showUserId" class="form-control required" style="position: absolute;top:0px;width:80%"  />
                            <#form:input path="userCode" id="userCode" class="form-control" style="position: absolute;top:0px;width:80%" type="hidden" />

                             <input name="doi" id="doid" type="hidden" value=${doid}>




                 </div>
                        <div class="col-sm-3" style="display: none;" id="faceShow">
                            <!--   <i style="position: absolute;cursor:pointer;left: 72px;top: 20px" title="拍照" onclick="collectPicture()" class="icon-cloud-upload"></i> -->
                            <!--   <img style="height: 50px;cursor: pointer;border-radius: 50px" id="showImg" src="${ctxStatic}/camera.jpg"  title="预览" onclick="jumpLayer()">-->
                            <a href="#" class="btn btn-default camera" id="lrFace"   title="录入人脸" onclick="collectPicture()"><i class="icon-camera"></i></a>
                        </div>
                    </div>
                 </div>

                        <div class="col-xs-6">
                            <div class="form-group">
                                <label class="control-label col-sm-4" title="">
                                    <span class="required ">*</span> ${text('领文人警号')}：<i class="fa icon-question hide"></i></label>
                                <div class="col-sm-8">
                                    <#form:input path="policeCode" id="policeCode" readonly="true" maxlength="20" class="form-control  required" />
                                </div>
                            </div>
                        </div>

             </div>



                        <#form:input path="face" id="pictureSrc" type="hidden" readonly="true" maxlength="20" class="form-control" />

                 </div>
                </div>

        </div>
    </div>
</div>


         </div>
         <div class="box-footer">
             <div class="row">
                 <div class="col-sm-offset-2 col-sm-10">
                     <% if (hasPermi('sd:docRecv:edit')){ %>
                     <button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('保 存')}</button>&nbsp;
                     <%}%>
                     <button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
                 </div>
             </div>
         </div>
     </#form:form>
 </div>
 </div>
 <% } %>
 <script>
     function getUser(){
      var str=$("#user").val();
      $("#showUserId").val($("#user option:checked").text())
         $("#userCode").val(str)
         if (str!=""){
             $.ajax({
                 type: "POST",
                 url: "${ctx}/sd/docDeliverTake/selectUserInfor",
                 data:{"userCode":str},
                 success: function (data) {
                     $("#policeCode").val(data)
                     document.getElementById("policeCode").setAttribute("readonly","true")

                 }

             })
         }else{
             $("#policeCode").val("")

         }





     }
     var i=0;
     var len;
     function get(){
         len=$("#showUserId").val();
     }
     function left(){
         if($("#showUserId").val()!=len){
             $("#policeCode").val("")
             $("#policeCode").removeAttr("readonly")
             $("#faceShow").css("display","block")
             // js.layer.msg("请录入人脸信息")
             $("#opt").attr("class","col-xs-6");
             $("#faceShow").attr("class","col-xs-2")
             if(i==0){
                 $("#pictureSrc").val(1)
             }


             i=i+1;

         }
     }
     function collectPicture(){
         js.layer.open({
             type: 2,
             area: [(js.layer.window.outerWidth-350)+'px',(js.layer.window.outerHeight-200)+'px'],
             title: '${text("拍照")}',
             resize: false,
             scrollbar: true,
             maxmin:true,
             content: '${ctx}/sd/collectPicture/form',
             success: function(layero, index){

             },
             btn: ['<i class="fa fa-check"></i> ${text("上传")}',
                 '<i class="fa fa-remove"></i> ${text("关闭")}'],
             btn1: function (index, layero) {
                 var win = layero.iframeWindow();
                 if (typeof(win.getFile()) == "undefined"){
                     js.layer.msg('请先拍照再提交!', {icon: 5});
                     return false;
                 }
                 console.log(typeof (win.getFile()));
                 var formData = new FormData;
                 formData.append("file", win.getFile());
                 $.ajax({
                     type: "POST",
                     url: "${ctx}/sd/collectPicture/uploadFile",
                     data: formData,
                     contentType: false,
                     processData: false,
                     success: function (data) {
                         if(data.result===Global.TRUE){
                             js.layer.msg(data.message, {icon: 1});
                             js.layer.close(index);
                             $('#pictureSrc').val(data.data);
                             facepath=win.getUrl();
                             $("#lrFace").attr("onclick","reset()")
                             $("#lrFace").attr("title","预览照片")
                             return true;
                         }else {
                             js.layer.msg(data.message, {icon: 5});
                             return false;
                         }

                     }
                 })
                 return false;

             }


         });
     }
     function reset(){
         js.layer.confirm("<div> <img src="+facepath+"  style='height: 300px;'> </div>",{
             title : "预览",
             skin : "my-skin",
             btn : [ '重拍', '取消' ],
             yes:function () {
                 collectPicture();
             }

         })
     }
     window.onload=function () {
         facepath=1;
     }
     $("#inputForm").validate({
         submitHandler: function(form){
             js.ajaxSubmitForm($(form), function(data){
                 if($("#pictureSrc").val()=="1"){
                     js.layer.msg("请录入人脸信息",{icon:5})
                     return false;
                 }
                 js.showMessage(data.message);
                 if(data.result == Global.TRUE){
                     window.location.href="${ctx}/sd/docDeliverRecord/list";
                    /* js.closeCurrentTabPage(function(contentWindow){

                         contentWindow.page();

                     });*/
                 }
             }, "json");
         }
     });


 </script>

